/**
 * Created by cb-dlhis on 17-1-17.
 */

import R from 'ramda';

const mainReducer = (state, action) => {
  if (typeof state === 'undefined') {
      state = {}
  }

  switch (action.type) {
    case 'GET_HOTEL_INFO':
          state.waitingSta = false;
          state.pages = action.data.navigatepageNums;
          state.hotels = action.data.list;
          state.pageNo = action.data.pageNum;
          state.searchKey = '';
          state.monthFree = '';
          state.dogNo = '';
          return state;
    case 'GET_SECRET_INFO':
          state.waitingSta = false;
          state.secretList = action.data.secretToShowList;
          return state;
    case 'GET_ORDERS_INFO':
          state.waitingSta = false;
          state.orderList = action.data.list;
          state.orderPages = action.data.navigatepageNums;
          state.orderPageNo = action.data.pageNum;
          return state;
    case 'GET_HOTEL_PARTNER':
          state.waitingSta = false;
          state.hotelInfo = action.data.hotelInfo;
          state.dealerInfo = action.data.dealerInfo;
          return state;
    case 'GET_PARTNER_INFO':
          state.waitingSta = false;
          state.partners = action.data.dealerList;
          state.partner = {};
          return state;
    case 'GET_HOTEL_LIST':
          state.waitingSta = false;
          state.hotelMap = action.data.hotelInfoList;
          return state;
    case 'GET_BUY_SECRET':
          state.waitingSta = false;
          state.buySecretInfo = action.data.buySecretNoLog.list;
          state.pages = action.data.buySecretNoLog.navigatepageNums;
          state.pageNo = action.data.buySecretNoLog.pageNum;
          state.secretHotelMap = action.data.hotelMap;
          return state;
    case 'GET_ORDER_INFO':
          state.waitingSta = false;
          state.orderInfo = action.data.historyOrderToshow.list;
          state.pages = action.data.historyOrderToshow.navigatepageNums;
          state.pageNo = action.data.historyOrderToshow.pageNum;
          state.statusMap = action.data.statusMap;
          return state;
    case 'SET_STATUS':
          state.status = action.data;
          return state;
    case 'SET_PATNER_INFO':
          state.partner[action.data.ele] = action.data.val;
          return state;
    case 'SET_HOTEL_ID':
          state.hotelId = action.data;
          return state;
    case 'SET_PAGE_NO':
          state.pageNo = action.data;
          return state;
    case 'SET_SEARCH_KEY':
          state.searchKey = action.data;
          return state;
    case 'SET_FREE_MONTH':
          state.monthFree = action.data;
          return state;
    case 'SET_DOG_NO':
          state.dogNo = action.data;
          return state;
    case 'OPEN_WAITING':
          state.waitingSta = true;
          return state;
    case 'OPEN_ALERT':
          state.waitingSta = false;
          state.alt = true;
          state.text = action.re;
          return state;
    case 'CLOSE_ALERT':
          state.alt = false;
          return state;
    default :
          return state;

  }
};

export default mainReducer;
